/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.bff.designtime.generator.api.service;

import com.inspur.edp.bff.api.manager.IFSManager;
import com.inspur.edp.bff.designtime.generator.api.VmApiGenContext;
import com.inspur.edp.caf.generator.baseInfo.TypeInfo;
import com.inspur.edp.caf.generator.item.InterfaceGeneratorContext;
import com.inspur.edp.cef.gencommon.MediateType;
import com.inspur.edp.cef.generator.apiGenerator.dataType.mgrAllInterface.MgrAllInterfaceGenerator;
import com.inspur.edp.das.commonmodel.IGspCommonModel;
import java.util.ArrayList;
import java.util.Arrays;
import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;

public class ServiceGenerator extends MgrAllInterfaceGenerator {


  private VmApiGenContext apiGenCtx;

  public ServiceGenerator(VmApiGenContext apiGenCtx) {
    super(apiGenCtx);
    this.apiGenCtx = apiGenCtx;
  }

  public static String getItemName(IGspCommonModel model) {
    return  "I"+model.getCode()+"Service" ;
  }

  @Override
  protected InterfaceGeneratorContext createInterfaceItemContext() {
    return new InterfaceGeneratorContext();
  }

  @Override
  protected java.util.ArrayList<ModifierKeyword> getAccessModifier() {
    return new java.util.ArrayList<ModifierKeyword>(
        java.util.Arrays.asList(ModifierKeyword.PUBLIC_KEYWORD));
  }

  //C# TO JAVA CONVERTER TODO TASK: Lambda expressions and anonymous methods are not converted by C# to Java Converter:
  @Override
  protected String getName() {
    return getItemName(apiGenCtx.getVmGenContext().getVm());
  }

  @Override
  protected java.util.ArrayList<TypeInfo> addParentInterfaces() {
    TypeInfo vmActionInterfaceType = new TypeInfo(
        apiGenCtx.getVmActionInterfaceType().getClassName());
    vmActionInterfaceType.setTypePackageName(apiGenCtx.getVmActionInterfaceType().getNamespace());
    TypeInfo fsMgrType = new TypeInfo(IFSManager.class);
    return new ArrayList<TypeInfo>(
        Arrays.asList(new TypeInfo[]{fsMgrType, vmActionInterfaceType}));
  }

  @Override
  protected void doInitialize() {
    apiGenCtx.setVmAllActionInterfaceType(new MediateType(compileUnit.getPackageName(), getName()));
  }

  ///#endregion
}
